package com.loveyukari.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class JsonUtils {

    private static ObjectMapper objectMapper = new ObjectMapper();

    public static String ObjectToString(Object object) throws IOException {
        return objectMapper.writeValueAsString(object);
    }

    public static JsonNode ObjectToJsonNode(Object object) throws IOException {
        return StringToJsonNode(ObjectToString(object));
    }

    public static JsonNode StringToJsonNode(String content) throws IOException {
        return objectMapper.readTree(content);
    }
}
